Skip to content

Conversation

CharlonTank
Copy link

@CharlonTank CharlonTank commented Dec 14, 2024

This PR fixes a compiler bug that occurred when using mapAccuml with explicit type annotations. The bug manifested as a compiler crash with the message:

thread blocked indefinitely in an MVar operation

The issue was that the compiler was incorrectly rejecting rank-2 type variables during generalization. These variables are in fact valid and required for higher-order functions like mapAccuml.

The fix updates the isGeneric function to explicitly allow rank-2 variables, enabling proper type inference for mapAccuml and similar functions.

Example of a test case that previously crashed but now works correctly:

func =
    List.Extra.mapAccuml
        (\acc x ->
            let
                newAcc = acc + 1
                result = x + acc
            in
            ( newAcc, result )
        )
        0
        [1, 2, 3]

⚠️ Note: This change is effectively a hotfix. While it resolves the immediate problem, it may introduce side effects elsewhere.

Copy link

Thanks for suggesting these code changes. To set expectations:

  • Pull requests are reviewed in batches, so it can take some time to get a response.
  • Smaller pull requests are easier to review. To fix nine typos, nine specific issues will always go faster than one big one. Learn why here.
  • Reviewers may not know as much as you about certain situations, so add links to supporting evidence for important claims, especially regarding standards for CSS, HTTP, URI, etc.

Finally, please be patient with the core team. They are trying their best with limited resources.

@CharlonTank CharlonTank marked this pull request as draft December 14, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant